package com.yc.controller;

import com.github.pagehelper.PageInfo;
import com.yc.domain.User;
import com.yc.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.jws.soap.SOAPBinding;

/**
 * Title:<br>
 * Description: <br>
 * Author:陈圆(chenyuan@bosssoft.com.cn) <br>
 * Date:2020/9/24
 */
@RestController
@RequestMapping("/testUser")
@Slf4j
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping("/getUser/{id}")
    public User getUserById(@PathVariable int id) {
        return userService.findUser(String.valueOf(id));
    }

    @GetMapping("/list")
    public PageInfo<User> listUsers(){
        Integer pageNum = 2, pageSize = 4;
        PageInfo pageInfo = userService.selectList(pageNum, pageSize);
        return pageInfo;
    }

    @PostMapping("/insert")
    public String insertUser(@Param("user") User user) {

        return userService.insertUser(user);
    }
}
